home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / lisp / elk-2_0.lha / elk-2.0 / src / exception.c < prev    next >
C/C++ Source or Header  |  1992-10-20  |  946b  |  43 lines

  1. #include "scheme.h"
  2.  
  3. int Intr_Was_Ignored;
  4.  
  5. #ifdef POSIX_SIGNALS
  6. sigset_t Sigset_Old, Sigset_Block;
  7. #endif
  8.  
  9. static Object V_Interrupt_Handler;
  10.  
  11. Init_Exception () {
  12.     Define_Variable (&V_Interrupt_Handler, "interrupt-handler", Null);
  13. #ifdef POSIX_SIGNALS
  14.     sigemptyset (&Sigset_Block);
  15.     sigaddset (&Sigset_Block, SIGINT);
  16.     (void)sigprocmask (0, (sigset_t *)0, &Sigset_Old);
  17. #endif
  18. }
  19.  
  20. /*ARGSUSED*/
  21. void Intr_Handler (sig) int sig; {
  22.     Object fun;
  23.  
  24. #ifndef RELIABLE_SIGNALS
  25.     (void)signal (SIGINT, Intr_Handler);
  26. #endif
  27.     Error_Tag = "interrupt-handler";
  28.     Reset_IO (1);
  29.     fun = Var_Get (V_Interrupt_Handler);
  30.     if (TYPE(fun) == T_Compound)
  31.     (void)Funcall (fun, Null, 0);
  32.     Format (Curr_Output_Port, "~%\7Interrupt!~%", 15, 0, (Object *)0);
  33.     Reset ();
  34.     /*NOTREACHED*/
  35. }
  36.  
  37. void Install_Intr_Handler () {
  38.     if (signal (SIGINT, SIG_IGN) == SIG_IGN)
  39.     Intr_Was_Ignored = 1;
  40.     else
  41.     (void)signal (SIGINT, Intr_Handler);
  42. }
  43.